﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using WisDom.SmartTMS.Data;
using WisDom.SmartTMS.Entities;
using WisDom.SmartTMS.EntityFrameworkCore;
using WisDom.SmartTMS.Enums;

namespace WisDom.SmartTMS.Repository
{
    public class BusinessAuditRepository : EfCoreRepository<SmartTMSDbContext, BusinessAudit, Guid>, IBusinessAuditRepository
    {
        //构造方法
        public BusinessAuditRepository(IDbContextProvider<SmartTMSDbContext> dbContextProvider) : base(dbContextProvider)
        {

        }
        /// <summary>
        /// 根据Id查询到审核表记录
        /// </summary>
        /// <param name="id"></param>
        /// <param name="businessType"></param>
        /// <returns></returns>
        public IQueryable<BusinessAudit> GetAuditById(Guid id, BusinessType businessType)
        {
            return this.Where(a => a.Id == id && a.BusinessTypeCode == businessType).Include(a => a.BusinessAuditLogs).AsQueryable();  //要返回审核日志明细（贪懒加载）
        }
        /// <summary>
        /// 返回业务类型的所有审核
        /// </summary>
        /// <param name="businessType"></param>
        /// <returns></returns>
        public IQueryable<BusinessAudit> GetAuditList(BusinessType businessType)
        {
            return this.Where(a => a.BusinessTypeCode == businessType).AsQueryable();
        }
    }
}
